package com.TTBook.impl.publisher.daoImpl;

import com.TTBook.core.publisher.dao.BookPublisherDAO;
import com.TTBook.core.publisher.model.BookPublisher;
import com.TTBook.core.publisher.model.BookPublisherCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BokPublisherDAOImpl extends SqlMapClientDaoSupport implements BookPublisherDAO {

    public BokPublisherDAOImpl() {
        super();
    }

    public int countByCriteria(BookPublisherCriteria criteria) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("ts_book_publisher.countByCriteria", criteria);
        return count.intValue();
    }

    public int deleteByCriteria(BookPublisherCriteria criteria) {
        int rows = getSqlMapClientTemplate().delete("ts_book_publisher.deleteByCriteria", criteria);
        return rows;
    }

    public void insert(BookPublisher record) {
        getSqlMapClientTemplate().insert("ts_book_publisher.insert", record);
    }

    public void insertSelective(BookPublisher record) {
        getSqlMapClientTemplate().insert("ts_book_publisher.insertSelective", record);
    }

    public List selectByCriteria(BookPublisherCriteria criteria) {
        List list = getSqlMapClientTemplate().queryForList("ts_book_publisher.selectByCriteria", criteria);
        return list;
    }

    public int updateByCriteriaSelective(BookPublisher record, BookPublisherCriteria criteria) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, criteria);
        int rows = getSqlMapClientTemplate().update("ts_book_publisher.updateByCriteriaSelective", parms);
        return rows;
    }

    public int updateByCriteria(BookPublisher record, BookPublisherCriteria example) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
        int rows = getSqlMapClientTemplate().update("ts_book_publisher.updateByCriteria", parms);
        return rows;
    }

    private static class UpdateByCriteriaParms extends BookPublisherCriteria {
        private Object record;

        public UpdateByCriteriaParms(Object record, BookPublisherCriteria criteria) {
            super(criteria);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}